/**
 * output package name
 */
package com.kingdee.eas.custom.aoyuan.aytime.basedata.client;

import java.awt.event.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Map;

import org.apache.log4j.Logger;

import com.kingdee.bos.BOSException;
import com.kingdee.bos.metadata.entity.EntityViewInfo;
import com.kingdee.bos.metadata.entity.FilterInfo;
import com.kingdee.bos.metadata.entity.FilterItemInfo;
import com.kingdee.bos.ui.face.CoreUIObject;
import com.kingdee.bos.ctrl.extendcontrols.KDBizPromptBox;
import com.kingdee.bos.ctrl.kdf.table.IRow;
import com.kingdee.bos.ctrl.kdf.table.KDTDefaultCellEditor;
import com.kingdee.bos.ctrl.swing.KDCheckBox;
import com.kingdee.bos.dao.IObjectValue;
import com.kingdee.eas.common.client.SysContext;
import com.kingdee.eas.custom.aoyuan.aytime.basedata.ScheduleGroupCollection;
import com.kingdee.eas.custom.aoyuan.aytime.basedata.ScheduleGroupFactory;
import com.kingdee.eas.custom.aoyuan.aytime.basedata.ScheduleGroupInfo;
import com.kingdee.eas.framework.*;

/**
 * output class name
 */
public class ScheduleGroupSelectorUI extends AbstractScheduleGroupSelectorUI
{
    private static final Logger logger = CoreUIObject.getLogger(ScheduleGroupSelectorUI.class);
    
    /**
     * output class constructor
     */
    public ScheduleGroupSelectorUI() throws Exception
    {
        super();

    	this.kDTable1.checkParsed();
    	
    	final KDCheckBox kdcheck = new KDCheckBox();
        KDTDefaultCellEditor kdtcelleditor = new KDTDefaultCellEditor(kdcheck);
        this.kDTable1.getColumn("chkSel").setEditor(kdtcelleditor);
    	
    }
//    @Override
    public void onLoad() throws Exception {
    	// TODO Auto-generated method stub
    	super.onLoad();
    	getAndShowData();
    }
    protected void getAndShowData()
    {
    	this.kDTable1.checkParsed();
    	this.kDTable1.removeRows();
    	if (SysContext.getSysContext().getCurrentHRUnit() != null)
    	{
    		EntityViewInfo evi= new EntityViewInfo();
    		FilterInfo filter = new FilterInfo();
    		filter.getFilterItems().add(new FilterItemInfo("HROrgUnit",SysContext.getSysContext().getCurrentHRUnit().getId().toString()));
    		evi.setFilter(filter);
    		ScheduleGroupCollection col = null;
			try {
				col = ScheduleGroupFactory.getRemoteInstance().getScheduleGroupCollection(evi);
			} catch (BOSException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
    		Iterator it = col.iterator();
    		while(it.hasNext())
    		{
    			ScheduleGroupInfo info = null;
    			info = (ScheduleGroupInfo)it.next();
    			IRow row = this.kDTable1.addRow();
    			row.getCell("id").setValue(info.getId().toString());
    			row.getCell("number").setValue(info.getNumber());
    			row.getCell("name").setValue(info.getName());
    			row.setUserObject(info);
    		}
    	}
    }

    /**
     * output storeFields method
     */
    public void storeFields()
    {
        super.storeFields();
    }

    /**
     * output actionPageSetup_actionPerformed
     */
    public void actionPageSetup_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionPageSetup_actionPerformed(e);
    }

    /**
     * output actionExitCurrent_actionPerformed
     */
    public void actionExitCurrent_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionExitCurrent_actionPerformed(e);
    }

    /**
     * output actionHelp_actionPerformed
     */
    public void actionHelp_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionHelp_actionPerformed(e);
    }

    /**
     * output actionAbout_actionPerformed
     */
    public void actionAbout_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionAbout_actionPerformed(e);
    }

    /**
     * output actionOnLoad_actionPerformed
     */
    public void actionOnLoad_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionOnLoad_actionPerformed(e);
    }

    /**
     * output actionSendMessage_actionPerformed
     */
    public void actionSendMessage_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionSendMessage_actionPerformed(e);
    }

    /**
     * output actionCalculator_actionPerformed
     */
    public void actionCalculator_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionCalculator_actionPerformed(e);
    }

    /**
     * output actionExport_actionPerformed
     */
    public void actionExport_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionExport_actionPerformed(e);
    }

    /**
     * output actionExportSelected_actionPerformed
     */
    public void actionExportSelected_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionExportSelected_actionPerformed(e);
    }

    /**
     * output actionRegProduct_actionPerformed
     */
    public void actionRegProduct_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionRegProduct_actionPerformed(e);
    }

    /**
     * output actionPersonalSite_actionPerformed
     */
    public void actionPersonalSite_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionPersonalSite_actionPerformed(e);
    }

    /**
     * output actionProcductVal_actionPerformed
     */
    public void actionProcductVal_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionProcductVal_actionPerformed(e);
    }

    /**
     * output actionExportSave_actionPerformed
     */
    public void actionExportSave_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionExportSave_actionPerformed(e);
    }

    /**
     * output actionExportSelectedSave_actionPerformed
     */
    public void actionExportSelectedSave_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionExportSelectedSave_actionPerformed(e);
    }

    /**
     * output actionKnowStore_actionPerformed
     */
    public void actionKnowStore_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionKnowStore_actionPerformed(e);
    }

    /**
     * output actionAnswer_actionPerformed
     */
    public void actionAnswer_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionAnswer_actionPerformed(e);
    }

    /**
     * output actionRemoteAssist_actionPerformed
     */
    public void actionRemoteAssist_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionRemoteAssist_actionPerformed(e);
    }

    /**
     * output actionPopupCopy_actionPerformed
     */
    public void actionPopupCopy_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionPopupCopy_actionPerformed(e);
    }

    /**
     * output actionHTMLForMail_actionPerformed
     */
    public void actionHTMLForMail_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionHTMLForMail_actionPerformed(e);
    }

    /**
     * output actionExcelForMail_actionPerformed
     */
    public void actionExcelForMail_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionExcelForMail_actionPerformed(e);
    }

    /**
     * output actionHTMLForRpt_actionPerformed
     */
    public void actionHTMLForRpt_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionHTMLForRpt_actionPerformed(e);
    }

    /**
     * output actionExcelForRpt_actionPerformed
     */
    public void actionExcelForRpt_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionExcelForRpt_actionPerformed(e);
    }

    /**
     * output actionLinkForRpt_actionPerformed
     */
    public void actionLinkForRpt_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionLinkForRpt_actionPerformed(e);
        
    }

//    @Override
	protected void btnClose_actionPerformed(ActionEvent e) throws Exception {
		// TODO Auto-generated method stub
		super.btnClose_actionPerformed(e);
		Map uiContext = this.getUIContext();

		if (uiContext.containsKey("result"))
		{
			Map map = (Map)uiContext.get("result");
			map.remove("resultobj");
		}
		this.getUIWindow().close();
	}
//	@Override
	protected void btnSelect_actionPerformed(ActionEvent e) throws Exception {
		// TODO Auto-generated method stub
		super.btnSelect_actionPerformed(e);
		Map uiContext = this.getUIContext();
		ArrayList ar = null;
		if (uiContext.containsKey("result"))
		{
			Map map = (Map)uiContext.get("result");
			if (map.containsKey("resultobj") ==false)
			{
				map.put("resultobj", new ArrayList());
			}
			ar = (ArrayList)map.get("resultobj");
			int totalLen = this.kDTable1.getRowCount();
			for(int i = 0;i<totalLen;i++)
			{
				IRow row = this.kDTable1.getRow(i);
				Boolean b =(Boolean) row.getCell("chkSel").getValue() ;
				if (b != null && b.booleanValue() )
				{
					ScheduleGroupInfo info =(ScheduleGroupInfo) row.getUserObject();
					ar.add(info);
				}
			}
		}
		this.getUIWindow().close();
	}
	/**
     * output actionPopupPaste_actionPerformed
     */
    public void actionPopupPaste_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionPopupPaste_actionPerformed(e);
    }

}